![]() |
PATH![]() |
![]() ![]() |
The Repeat Until form of the Repeat statement repeats a group of statements until a particular condition, specified in a Boolean expression, is met.
repeat until Boolean
[ statement ]...
end [ repeat ]
Boolean is an expression whose value is true or false . The statements in the loop are repeated until Boolean becomes true . If Boolean is true when entering the loop, the statements in the loop are not executed.
The following example is based on Figure 2-4, which shows a script that copies information from a database to a spreadsheet. The script uses the Repeat Until form of the Repeat statement, copying an inventory count from each database record to a spreadsheet cell until a loop variable exceeds the number of records. The script assumes the database and spreadsheet files are already open.
tell application "FileMaker Pro"
set numberRecords to count records of document "Inventory DB"
set loopCount to 1
repeat until loopCount > numberRecords
copy cell "Count" of record loopCount ¬
of document "Inventory DB" to partCount
set cellName to "B" & ((loopCount + 1) as string)
tell application "AppleWorks"
set cell cellName of spreadsheet of document ¬
"Spreadsheet" to partCount as string
end tell
set loopCount to loopCount + 1
end repeat
end tell